import React, { useState } from 'react';
import { View, TouchableOpacity, Text } from 'react-native';

const RatingBar = ({ maxStars=5, onRate }) => {
  const [rating, setRating] = useState(0);

  return (
    <View style={styles.container}>
      {[...Array(maxStars)].map((_, i) => (
        <TouchableOpacity key={i} onPress={() => {
          setRating(i+1);
          onRate(i+1);
        }}>
          <Text>{i+1 <= rating ? '★' : '☆'}</Text>
        </TouchableOpacity>
      ))}
    </View>
  );
};

export default RatingBar;